package com.ruoyi.shis.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.shis.domain.ShisPtcg;
import com.ruoyi.shis.service.IShisPtcgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 实时监控_平台查岗Controller
 * 
 * @author ruoyi
 * @date 2023-10-07
 */
@RestController
@RequestMapping("/system/ptcg")
public class ShisPtcgController extends BaseController
{
    @Autowired
    private IShisPtcgService shisPtcgService;

    /**
     * 查询实时监控_平台查岗列表
     */
    @PreAuthorize("@ss.hasPermi('system:ptcg:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShisPtcg shisPtcg)
    {
        startPage();
        List<ShisPtcg> list = shisPtcgService.selectShisPtcgList(shisPtcg);
        return getDataTable(list);
    }

    /**
     * 导出实时监控_平台查岗列表
     */
    @PreAuthorize("@ss.hasPermi('system:ptcg:export')")
    @Log(title = "实时监控_平台查岗", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShisPtcg shisPtcg)
    {
        List<ShisPtcg> list = shisPtcgService.selectShisPtcgList(shisPtcg);
        ExcelUtil<ShisPtcg> util = new ExcelUtil<ShisPtcg>(ShisPtcg.class);
        util.exportExcel(response, list, "实时监控_平台查岗数据");
    }

    /**
     * 获取实时监控_平台查岗详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ptcg:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shisPtcgService.selectShisPtcgById(id));
    }

    /**
     * 新增实时监控_平台查岗
     */
    @PreAuthorize("@ss.hasPermi('system:ptcg:add')")
    @Log(title = "实时监控_平台查岗", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShisPtcg shisPtcg)
    {
        return toAjax(shisPtcgService.insertShisPtcg(shisPtcg));
    }

    /**
     * 修改实时监控_平台查岗
     */
    @PreAuthorize("@ss.hasPermi('system:ptcg:edit')")
    @Log(title = "实时监控_平台查岗", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShisPtcg shisPtcg)
    {
        return toAjax(shisPtcgService.updateShisPtcg(shisPtcg));
    }

    /**
     * 删除实时监控_平台查岗
     */
    @PreAuthorize("@ss.hasPermi('system:ptcg:remove')")
    @Log(title = "实时监控_平台查岗", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shisPtcgService.deleteShisPtcgByIds(ids));
    }
}
